/*
 * Server.h
 *
 *  Created on: 23.06.2012
 *      Author: sebastian
 */

#ifndef SERVER_H_
#define SERVER_H_

#include <sys/socket.h>
#include <sys/un.h>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <arpa/inet.h>


class Server {
private:
	struct sockaddr_in bindAddr_;
	int serverSocket_;

	void tryAccept();

	bool unBind();

	bool isRunning_;

	pthread_t thread_;

public:

	static void *run(void * s);
	static std::string generateNormalHeader(int bodyLen);


	Server(int PORT);

	bool start(); //TODO: mayput start, stop and run in extra class called Threaded.... then use onStart, onStop...
	bool stop();
	virtual ~Server();
};

#endif /* SERVER_H_ */
